package xyz.erupt.flow.service;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import org.camunda.bpm.engine.history.HistoricTaskInstance;
import org.camunda.bpm.engine.task.Task;
import org.springframework.data.domain.Page;
import org.springframework.transaction.annotation.Transactional;
import xyz.erupt.flow.bean.vo.WorkFlowHistoryTaskDetailVo;
import xyz.erupt.flow.bean.vo.WorkFlowHistoryTaskVo;
import xyz.erupt.flow.bean.vo.WorkFlowTaskDetailVo;
import xyz.erupt.flow.bean.vo.WorkFlowTaskVo;
import xyz.erupt.flow.data.vo.VO_OaTaskHistory;

import java.util.List;

public interface WorkFlowTaskService {

    @Transactional(rollbackFor = Exception.class)
    void startFlowIncludeHistory(Long workFlowDefinitionId, JSONObject formData);

    @Transactional(rollbackFor = Exception.class)
    boolean startFlow(Long workFlowDefinitionId, JSONObject formData);

    @Transactional(rollbackFor = Exception.class)
    void startFlow(String processKey, JSONObject formData);

    Page<Task> getAllTaskByAccount(String account, String keyword, int pageIndex, int pageSize);

    Page<WorkFlowTaskVo> getAllWorkFlowTaskByAccount(String account, String keyword, int pageIndex, int pageSize);

    Page<HistoricTaskInstance> getAllHistoryTaskByAccount(String account, String keyword, int pageIndex, int pageSize);

    Page<WorkFlowHistoryTaskVo> getAllWorkFlowHistoryTaskByAccount(String account, String keyword, int pageIndex, int pageSize);

    WorkFlowTaskDetailVo getTaskDetailById(String taskId);

    WorkFlowHistoryTaskDetailVo getHistoryTaskDetail(String taskId);

    @Transactional(rollbackFor = Exception.class)
    void complete(String taskId, String account, JSONObject formData);

    @Transactional(rollbackFor = Exception.class)
    void refuse(String taskId, String account, String reason);

    List<VO_OaTaskHistory> previewInstance(String taskId);
}
